using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Voodoo.Sauce.Internal.Extension;

namespace Voodoo.Sauce.Debugger
{
	public class EventInformationLineItem : MonoBehaviour
	{
		[SerializeField]
		private Text field;

		[SerializeField]
		private Button copyButton;

		private string _key;

		private string _value;

		private const int MAX_LENGTH = 50;

		private void Awake()
		{
			copyButton.onClick.AddListener(delegate
			{
				_value.CopyToClipboard();
			});
		}

		public void UpdateData(KeyValuePair<string, object> information)
		{
			_key = information.Key;
			_value = ((information.Value != null) ? information.Value.ToString() : "");
			if ((_key + ": " + _value).Length <= 50)
			{
				field.text = _key + ": " + _value.BoldText();
			}
			else
			{
				field.text = _key + ": " + _value.Truncate(50 - _key.Length - 5).BoldText();
			}
		}
	}
}
